package com.cy.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cy.common.vo.JsonResult;
import com.cy.entity.SysUser;

/**
 * 
 * @author ZHANGSIMIN
 * @version 1.1
 */
@Controller
@RequestMapping("/")
public class PageController {
	
	/**
	 * @author ZHANGSIMIN
	 * @return 登录页面响应
	 * @since 1.1
	 */
	@RequestMapping("doLoginUI")
	public String doLoginUI() {
		return "login";
	}
	
	/**
	 * @author ZHANGSIMIN
	 * @return 注册页面响应
	 * @since 1.1
	 */
	@RequestMapping("doRegUI")
	public String doRegUI() {
		return "reg";
	}
	
	/**
	 * @author ZHANGSIMIN
	 * @param moduleUI 子页面URL
	 * @return 子页面响应
	 * @since 1.0
	 */
	@RequestMapping("{moduleUI}")
	public String doModuleUI(@PathVariable String moduleUI) {
		return moduleUI;
	}
	
	@RequestMapping("doGetUsername")
	@ResponseBody
	public JsonResult doGetUsername(HttpServletRequest request) {
		
		HttpSession se = request.getSession();
		String username = (String)se.getAttribute("username");
		int id = (Integer)se.getAttribute("id");
		SysUser user = new SysUser();
		user.setId(id);
		user.setUsername(username);
		System.out.println("12345");
		JsonResult jr = new JsonResult(username);
		jr.setData(user);
		return jr;
	}
	
	
}
